package com.smartEdu.handler.redis.util;

import org.apache.commons.lang3.SystemUtils;
import com.smartEdu.commons.LogCvt;



public final class SystemUtil {


	public static String getStackMessage(final StackTraceElement[] stacks) {
		if (stacks == null) {
			return null;
		}
		int size = stacks.length;
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i < size; i++) {
			StackTraceElement ste = stacks[i];
			if (i > 1) {
				sb.append("\t");
			}
			sb.append(ste.toString()).append("\n");
		}
		return sb.toString();
	}

	public static long currentTimeMillis() {
		return System.currentTimeMillis();
	}


	/**
	 * 休眠</br>
	 * 
	 * @param mills
	 *            休眠时间，单位毫秒
	 */
	public static void sleep(long mills) {
		try {
			Thread.sleep(mills);
		}
		catch (InterruptedException e) {
			LogCvt.error(e.getMessage(), e);
		}
	}

	/**
	 * 判断是否非Windows环境.
	 * 
	 * @return
	 */
	public static boolean isNotWindows() {
		return !SystemUtils.IS_OS_WINDOWS;
	}

	public static boolean isWindows() {
		return SystemUtils.IS_OS_WINDOWS;
	}

	/**
	 * 判断是否非Linux环境.
	 * 
	 * @return
	 */
	public static boolean isNotLinux() {
		return !SystemUtils.IS_OS_LINUX;
	}
}
